package com.offcn.dao.Impl;

import com.offcn.dao.BaseDao;
import com.offcn.dao.CourseDetailDao;
import com.offcn.entity.CourseDetail;

import java.util.List;

public class CourseDetailDaoImpl extends BaseDao<CourseDetail> implements CourseDetailDao {
    @Override
    public int addDetail(CourseDetail detail) {
        String sql = "insert into coursedetail values(null, ?, ?, ?, ?, ?)";
        return dml(sql, detail.getName(), detail.getType(), detail.getUrl(),
                detail.getStart_data().replace("-", "."), detail.getCid());
    }

    @Override
    public List<CourseDetail> findByCid(int cid) {
        String sql = "select * from coursedetail where cid = ?";
        return moreLine(sql,CourseDetail.class,cid);
    }

    @Override
    public List<Object> findByCid(String cid) {
        String sql = "select distinct type from coursedetail where cid = ? order by start_data asc";
        return singleColumn(sql,cid);
    }
}
